﻿using Engine;
using Engine.Graphics;
using Game;

namespace MFTrain
{
    public class MFScreenSpaceSteamRenderer : ScreenSpaceFireRenderer
    {
        public MFScreenSpaceSteamRenderer(int particlesCount)
            : base(particlesCount)
        {
            m_texture = ContentManager.Get<Texture2D>("MF/Train/SteamParticle");
        }

        public new void DrawParticle(TexturedBatch2D batch, Particle particle, float depth, Color color)
        {
            Vector2 corner = particle.Position - particle.Size / 2f;
            Vector2 corner2 = particle.Position + particle.Size / 2f;
            int textureSlot = particle.TextureSlot;
            Vector2 vector = new Vector2(textureSlot % 3, textureSlot / 3);
            float num = 0f;
            float num2 = 1f;
            float num3 = 0f;
            float num4 = 1f;
            if (particle.FlipX)
            {
                num = 1f - num;
                num2 = 1f - num2;
            }

            if (particle.FlipY)
            {
                num3 = 1f - num3;
                num4 = 1f - num4;
            }

            Vector2 texCoord = (vector + new Vector2(num, num3)) * (1f / 3f);
            Vector2 texCoord2 = (vector + new Vector2(num2, num4)) * (1f / 3f);
            batch.QueueQuad(corner, corner2, depth, texCoord, texCoord2, color);
        }
    }
}